#ifndef FRAMEFACTORY_H
#define FRAMEFACTORY_H
#include <iostream>
#include <string>
using std::string;
#include <map>
#include <algorithm>
#include "frame.h"
#include "gamedata.h"

class FrameFactory {
public:

  FrameFactory() :gamedata(Gamedata::getInstance()), frames( std::map<string, Frame*>() ) {}
  
  static FrameFactory * getInstance(){
	if (!instance) instance = new FrameFactory(); 
	return instance;
  }

  virtual ~FrameFactory();

  // Must pass both width and height here because the sprite might
  // be embedded in a sprite sheet; i.e., only part of the surface.
  virtual Frame* getFrame(const string& name,const string& prefix);
protected:
  const Gamedata* gamedata;
  
private:
  static FrameFactory * instance;
  
  std::map<string, Frame*> frames;

  FrameFactory(const FrameFactory&);
  FrameFactory& operator=(const FrameFactory&);
};
#endif
